﻿using System;
using System.Web.UI;
using Crimson;

public partial class Admin_Crimson_Controls_InfoTypeTreeSelector : UserControl
{
    public InfoType SelectedInfoType
    {
        get
        {
            if (SelectedInfoTypeId != Guid.Empty)
            {
                return new InfoType(SelectedInfoTypeId, showLinkButton.Text);
            }
            return null;
        }
        set
        {
            if (value != null)
            {
                showLinkButton.Text = value.Name;
                HiddenBoxSelectedParent.Value = value.Id.ToString();
            }
            else
            {
                showLinkButton.Text = "根节点";
                HiddenBoxSelectedParent.Value = "";
            }
        }
    }

    public Guid SelectedInfoTypeId
    {
        get
        {
            if (String.IsNullOrEmpty(HiddenBoxSelectedParent.Value))
            {
                return Guid.Empty;
            }
            return new Guid(HiddenBoxSelectedParent.Value);
        }
    }

    public string CanNotSelectedId
    {
        set { ViewState["CanNotSelectedId"] = value; }
        get { return ViewState["CanNotSelectedId"] == null ? null : (string) ViewState["CanNotSelectedId"]; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        selectParentTree.ClientMethod = "treeViewOnclick";
    }

    public void DataBindTree()
    {
        selectParentTree.DataBindTree();
    }
}